[POWERPC][XEN] Alloc IOMMU to map a Foreign page
authorJimi Xenidis <jimix@watson.ibm.com>
Sat, 7 Oct 2006 19:38:27 +0000 (15:38 -0400)
committerJimi Xenidis <jimix@watson.ibm.com>
Sat, 7 Oct 2006 19:38:27 +0000 (15:38 -0400)
VIO to a physical device reulsts in the granted page getting mapped
into the IOMMU.
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
--HG--
extra : transplant_source : %AE%BE%E0%04%E5%17%FB9%1C%13Et%9Cq%A2%28a%EC%25M

xen/arch/powerpc/iommu.c

index a6c5fa093febee8efcf3a26517ae4ee2d9019ba6..46a415debc9732dcd7fdb3b7d389946c7e9cfece 100644 (file)
 #include "tce.h"
 #include "iommu.h"
 
+#ifdef DEBUG
+#define DBG(fmt...) printk(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
 struct iommu_funcs {
     int (*iommu_put)(ulong, union tce);
 };
@@ -46,16 +52,31 @@ int iommu_put(u32 buid, ulong ioba, union tce tce)
     struct domain *d = v->domain;
 
     if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put != NULL) {
-        ulong gpfn;
+        ulong gmfn;
         ulong mfn;
+        int mtype;
 
-        gpfn = tce.tce_bits.tce_rpn;
-        mfn = gmfn_to_mfn(d, gpfn);
+        gmfn = tce.tce_bits.tce_rpn;
+
+        
+        mfn = pfn2mfn(d, gmfn, &mtype);
         if (mfn != INVALID_MFN) {
-#ifdef DEBUG
-            printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__,
-                   ioba, pfn, mfn);
-#endif
+            switch (mtype) {
+            case PFN_TYPE_RMA:
+            case PFN_TYPE_LOGICAL:
+                break;
+            case PFN_TYPE_FOREIGN:
+                DBG("%s: assigning to Foriegn page: "
+                    "gmfn: 0x%lx mfn: 0x%lx\n",  __func__, gmfn, mfn);
+                break;
+            default:
+                printk("%s: unsupported type[%d]: gmfn: 0x%lx mfn: 0x%lx\n",
+                       __func__, mtype, gmfn, mfn);
+                return -1;
+            break;
+            }
+            DBG("%s: ioba=0x%lx gmfn=0x%lx mfn=0x%lx\n", __func__,
+                ioba, gmfn, mfn);
             tce.tce_bits.tce_rpn = mfn;
             return iommu_phbs[buid].iommu_put(ioba, tce);
         }